2018-10-01 19:22:59 +00:00
|
|
|
== code
|
|
|
|
|
2018-10-01 22:12:56 +00:00
|
|
|
# instruction effective address operand displacement immediate
|
|
|
|
# op subop mod rm32 base index scale r32
|
|
|
|
# 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes
|
|
|
|
|
2018-10-01 19:22:59 +00:00
|
|
|
write_stderr: # s : (address array byte) -> <void>
|
|
|
|
# prolog
|
|
|
|
55/push-EBP
|
|
|
|
89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP
|
|
|
|
# save registers
|
|
|
|
50/push-EAX
|
|
|
|
51/push-ECX
|
|
|
|
52/push-EDX
|
|
|
|
53/push-EBX
|
|
|
|
# write(2/stderr, (data) s+4, (size) *s)
|
|
|
|
# fd = 2 (stderr)
|
2018-10-01 22:35:56 +00:00
|
|
|
bb/copy . . . . . . . 2/imm32 # copy to EBX
|
2018-10-01 19:22:59 +00:00
|
|
|
# x = s+4
|
2018-10-03 03:58:39 +00:00
|
|
|
8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX
|
2018-10-01 22:35:56 +00:00
|
|
|
81 0/subop/add 3/mod/direct 1/rm32/ECX . . . . . 4/imm32 # add to ECX
|
2018-10-01 19:22:59 +00:00
|
|
|
# size = *s
|
2018-10-03 03:58:39 +00:00
|
|
|
8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 2/r32/EDX 8/disp8 . # copy *(EBP+8) to EDX
|
2018-10-01 19:22:59 +00:00
|
|
|
8b/copy 0/mod/indirect 2/rm32/EDX . . . 2/r32/EDX . . # copy *EDX to EDX
|
|
|
|
# call write()
|
2018-10-01 22:35:56 +00:00
|
|
|
b8/copy . . . . . . . 4/imm32/write # copy to EAX
|
2018-10-01 19:22:59 +00:00
|
|
|
cd/syscall 0x80/imm8
|
|
|
|
# restore registers
|
|
|
|
5b/pop-to-EBX
|
|
|
|
5a/pop-to-EDX
|
|
|
|
59/pop-to-ECX
|
|
|
|
58/pop-to-EAX
|
|
|
|
# end
|
|
|
|
89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP
|
|
|
|
5d/pop-to-EBP
|
|
|
|
c3/return
|
2018-10-01 22:12:56 +00:00
|
|
|
|
|
|
|
# vim:ft=subx:nowrap:tw&
|